import { defineStore } from 'pinia'
export const tagsStore = defineStore('tags', {
  state: () => ({
    menuTags: [
      {
        path: '/system/frist/frist',
        name: '首页',
        meta: { header: '首页', buttons: [], type: 'C', icon: 'HomeFilled' },
        props: { default: false },
        children: [],
        instances: { default: null },
        leaveGuards: {},
        updateGuards: {},
        enterCallbacks: {},
        components: {
          default: {
            __hmrId: 'a40cedcb',
            __file: 'E:/studyCode/wxapp/web/web/src/page/home/main/system/frist/frist.vue'
          }
        }
      }
    ] as any[]
  }),
  actions: {
    setTags(tag: any) {
      const en = this.menuTags.filter(s => s.path === tag.path)
      if (tag && tag.path !== '/system/frist/frist' && (!en || (en && en.length == 0))) {
        this.menuTags = this.menuTags.concat(tag)
      }
    },
    remove(tag: any) {
      if (tag && this.menuTags && tag.path !== '/system/frist/frist') {
        this.menuTags = this.menuTags.filter(s => s.path !== tag.path)
      }
    },
    batchRemove(tags: any[]) {
      if (tags && this.menuTags) {
        tags.forEach(ss => {
          this.menuTags = this.menuTags.filter(st => st.path !== ss.path)
        })
      }
    },
    removeAll() {
      this.menuTags = [
        {
          path: '/system/frist/frist',
          name: '首页',
          meta: { header: '首页', buttons: [], type: 'C', icon: 'HomeFilled' },
          props: { default: false },
          children: [],
          instances: { default: null },
          leaveGuards: {},
          updateGuards: {},
          enterCallbacks: {},
          components: {
            default: {
              __hmrId: 'a40cedcb',
              __file: 'E:/studyCode/wxapp/web/web/src/page/home/main/system/frist/frist.vue'
            }
          }
        }
      ]
    }
  },
  persist: true
})
